package com.zxm.dubbodemo.consumer.controller;

import com.zxm.dubbodemo.api.DemoServiceFacade;
import com.zxm.dubbodemo.api.UserDto;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope
@RestController
public class HelloController {
    @Reference(
            version = "${demo.service.version}",
            application = "${dubbo.application.id}",
            registry = "${dubbo.registry.id}",
            timeout = 2000)
  private DemoServiceFacade demoService;

  @Value(value = "${user.age}")
  private String age;

  @GetMapping("hello/{name}")
  public String sayHello(@PathVariable String name) {
    UserDto ut = demoService.sayHello(name);
    return ut.getName();
  }
}
